package com.example.test.service.impl;

import com.example.test.domain.User;
import com.example.test.repository.IUserRepository;
import com.example.test.service.IUserService;
import org.springframework.data.domain.Example;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends BaseServiceImpl<User, Long> implements IUserService {
    public UserServiceImpl(IUserRepository repository) {
        super(repository);
    }

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        User example = new User();
        example.setUsername(username);
        return repository.findOne(Example.of(example)).orElse(null);
    }
}
